package com.jiangyg.mall.coupon.service;

import com.jiangyg.mall.core.support.restful.Pagination;
import com.jiangyg.mall.coupon.dao.CouponHistoryDao;
import com.jiangyg.mall.coupon.dto.CouponHistoryDTO;
import com.jiangyg.mall.coupon.entity.CouponHistory;
import com.jiangyg.mall.coupon.vo.CouponHistoryVO;
import com.jiangyg.mall.db.mybatis.BaseServiceImpl;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class CouponHistoryServiceImpl extends BaseServiceImpl<CouponHistoryDao, CouponHistory> implements CouponHistoryService {

    @Autowired
    public CouponHistoryServiceImpl(CouponHistoryDao couponHistoryDao) {
        super(couponHistoryDao);
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public Pagination<CouponHistoryVO> selectPagination(Pagination<CouponHistoryVO> pagination) throws Exception {
        return this.executeSelectPagination(pagination, CouponHistoryVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean saveOrUpdate(CouponHistoryDTO dto) throws Exception {
        return this.executeSaveOrUpdate(dto) > 0;
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public CouponHistoryVO selectById(Long couponHistoryId) throws Exception {
        return this.executeSelectById(couponHistoryId, CouponHistoryVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean delete(List<Long> couponHistoryIds) {
        return this.baseMapper.deleteBatchIds(couponHistoryIds) > 0;
    }

}
